package com.niit.session7.loop;

import java.util.Scanner;

public class UserLogin {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入用户名：");
		String uername = sc.next();
		System.out.print("请输入密码：");
		String password = sc.next();
//		while (true) 是执行一个死循环
		while (true) {
//			判断字符串是否相等要用equals()方法
			if(uername.equals("trout") && password.equals("123456")) {
				System.out.println("登录成功！");
//				break用于跳出死循环
				break;
			}else {
				System.out.println("登录失败！");
				System.out.print("请输入用户名：");
				uername = sc.next();
				System.out.print("请输入密码：");
				password = sc.next();
			}
		}
	}

}
